package com.xiao.live.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.xiao.live.entity.LiveOrderEntity;
import com.xiao.live.service.LiveOrderService;
import com.xiao.group.common.utils.PageUtils;
import com.xiao.group.common.utils.R;



/**
 * 直播中的直播订单表
 *
 * @author 韩国涛
 * @email 2845009006@gmail.com
 * @date 2021-09-24 19:04:06
 */
@RestController
@RequestMapping("live/liveorder")
public class LiveOrderController {
    @Autowired
    private LiveOrderService liveOrderService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = liveOrderService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{orderid}")
    public R info(@PathVariable("orderid") Integer orderid){
		LiveOrderEntity liveOrder = liveOrderService.getById(orderid);

        return R.ok().put("liveOrder", liveOrder);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody LiveOrderEntity liveOrder){
		liveOrderService.save(liveOrder);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody LiveOrderEntity liveOrder){
		liveOrderService.updateById(liveOrder);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] orderids){
		liveOrderService.removeByIds(Arrays.asList(orderids));

        return R.ok();
    }

}
